package com.seari.client;

import com.seari.service.AppCacheService;
import com.seari.service.OperateService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @ClassName TosOperateClient
 * @Description tos运营信息
 * @Author zhangYanKun
 * @Date 2021/5/20 19:58
 * @Version 1.0
 */
@Component("TosOperateClient")
public class TosOperateClient extends BaseClient{

    protected static Logger log = LoggerFactory.getLogger(FullLoadClient.class);

    @Autowired
    private AppCacheService cacheService;

    @Autowired
    private OperateService operateService;

    @Override
    public void process() throws Exception {
        Map<String,Object> result = null;
        // 将限流车站和限流区间存入缓存
        try{
            result = operateService.getLimitStation();
        }catch (RuntimeException e){
            log.error(e.getMessage());
        }
        if(result != null && result.size() > 0){
            cacheService.refreshCache("limitStationAndSection", result);
            log.info("limitStationInfo and limitSection save cache successfully");
        }else {
            log.error("limitStationInfo get failed,doesn't save cache");
        }

    }
}
